<?php
require_once "../../PCO.php";
require_once "../../global-themis/Classes/responsable.class";
require_once "../../global-themis/functions/functions.php";
$nom_cli="";
$sir_cli="";
$res_cli="";
$code_res="";
if($_GET[VAR_GET_RES]!=""){
	$code_res=$_GET[VAR_GET_RES]; // recuperer le numero du client en GET.
}

else {
	echo "Error";
}
?>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta name="keywords" content="">
	<meta name="description" content="">
	<title>gestionnaire <?php echo $code_res; ?></title>
	<link rel="stylesheet" type="text/css" href="../../global-themis/css/easyui.css">
	<link rel="stylesheet" type="text/css" href="../../global-themis/css/themisstyle.css">
	<link rel="stylesheet" type="text/css" href="../../global-themis/css/icon.css">
	<script type="text/javascript" src="../../global-themis/js/jquery.js"></script>
	<script type="text/javascript" src="../../global-themis/js/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="../../global-themis/js/cookie.jquery.js"></script>	
	<script>
	$(document).ready(function(){
		$(".panel-body").css("background","#AFCBF3");
		$(".tabs").append("<span style='margin-left:5%'><select id='cli' ><option value='1'>Onglet 1</option><option value='2'>Onglet 2</option><option value='3'>Onglet 3</option></select>&nbsp;<input size='15' type='text' id='add' />&nbsp;<input type='button' value='MAJ titre' id='ajout' /></span>");
		var id="tabs";
		var cook="";
		$('.tabs-title').each(function(i){
		$(this).attr("id", i+1);
		});
		if($.cookie(id)==null){
			$("#1").html("Onglet 1");
			$("#2").html("Onglet 2");
			$("#3").html("Onglet 3");
			cook=$("#1").text()+"|"+$("#2").text()+"|"+$("#3").text();
			$.cookie(id,cook);
		}
		else {
			var col=$.cookie(id).split("|");
			$("#1").html(col[0]);
			$("#2").html(col[1]);
			$("#3").html(col[2]);
		}
		});
	</script>
	<script>
	$(document).ready(function(){
		$("#ajout").click(function(){
			var id="tabs";
			var cook="";
			var onglet=$("#cli").val();
			var texte=$('#add').val();
			if(texte !=""){
				if(onglet==1){
					$("#"+onglet).text(texte);
					cook=$("#"+onglet).text()+"|"+$("#2").text()+"|"+$("#3").text();
					$.cookie(id, cook);
				}				
				else if(onglet==2){
					$("#"+onglet).text(texte);
					cook=$("#1").text()+"|"+$("#"+onglet).text()+"|"+$("#3").text();
					$.cookie(id, cook);
				
				}				
				
				else if(onglet==3){
					$("#"+onglet).text(texte);
					cook=$("#1").text()+"|"+$("#2").text()+"|"+$("#"+onglet).text();
					$.cookie(id, cook);
				}
				else {
					alert("Erreur : vous avez tapé un titre qui existe dejà.")
				}
			}
			else {
				alert("Remplissez le champ texte svp");
			}
		})
	});
	</script>
	<script type="text/javascript">	
		$(document).ready(function(){
			$("#note").keyup(function(){
				$("#sauv").css("display", "inline");
				$("#annul").css("display", "inline");
			});
		});
    </script>	
	<script type="text/javascript">	
		$(document).ready(function(){
			var valu="<?php echo getNote($code_res); ?>";
			if($.trim(valu)=="")
				valu="Inserer une note sur le gestionnaire: <?php echo $code_res; ?>";
			var reg=new RegExp("(,)", "g");
			 valu=valu.replace(reg, "\n");
			 $("#note").val(valu);
		});
    </script>		
	<script type="text/javascript">	
		$(document).ready(function(){
			$("#sauv").click(function(){
				var textar=$.trim($("#note").val());
				textar = textar.replace(/[@#$%\^&*=_+"'\/<>\\\|{}\[\]]/g,"");
				textar = textar.replace(/[\t ]+/g,' ');
				textar = textar.replace(/\n{1,}/g,'\n\n');
				textar = textar.split(/\n/);
				var dataString = "id=<?php echo $code_res;?>&value="+textar;
				// alert(dataString);
				$.ajax	({
					type: "POST",
					url: "../post-it/note.php",
					data: dataString,
					cache: false,
					success: function(html){
						if(textar=="")
							$("#note").val("Inserer une note sur le gestionnaire: <?php echo $code_res; ?>");
						$("#sauv").css("display", "none");
						$("#annul").css("display", "none");
					},
					error: function(xhr, status, errorThrown) {
							alert(xhr+ ' : error ajax - contactez DESI : status '+ status + ' && ' + errorThrown);
					}
				});
			})
			$("#annul").click(function(){
				var valu="<?php echo getNote($code_res); ?>";
				if($.trim(valu)=="")
					valu="Inserer une note sur le gestionnaire: <?php echo $code_res; ?>";
				var reg=new RegExp("(,)", "g");
				valu=valu.replace(reg, "\n");
				$("#note").val(valu);
				$("#sauv").css("display", "none");
				$("#annul").css("display", "none");
			});
		});
    </script>
</head>
<body>

		<FIELDSET style='width:45%;float:right;overflow:visible;'>
			<LEGEND align=top> Post-it:</LEGEND> 
			<textarea cols="68" rows='4'  id="note" style="background-color:#eedd82;"  >
			</textarea><br>
			<input type='button' value='Sauvegarder' id='sauv' style="display: none;"/>
			<input type='button' value='Annuler' id='annul' style="display: none;"/>
		</FIELDSET>
	</div><br>
	<div id="tt" class="easyui-tabs" width="95%" height="480%" style='background:#AFCBF3;margin: 117px 0px 0px 0px;'>
		<div title="" id="c1" height="100%">
			<iframe scrolling="no" frameborder="0"   src="./R1/igoogle_resp.php?<?php echo VAR_GET_RES."=".$code_res; ?>" style="width:100%;height:450%;"></iframe>
		</div>
		
		<div title="" id="c2">
			<iframe scrolling="auto" frameborder="0"  src="./R3/igoogle_resp.php?<?php echo VAR_GET_RES."=".$code_res; ?>" style="width:100%;height:450%;"></iframe>
		</div>
		
		<div title="" id="c3">
			<iframe scrolling="auto" frameborder="0"  src="./R2/igoogle_resp.php?<?php echo VAR_GET_RES."=".$code_res; ?>" style="width:100%;height:450%;"></iframe>
		</div>
	</div>
</body>
</html>